<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            const p1 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(1111);
                }, 1000);
            });
            const p2 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    reject(222);
                }, 2000);
            });
            const p3 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(3333);
                }, 3000);
            });
            // 当有promise发生错误，也会执行后面的promise,且以对象形式输出
            Promise.allSettled([p1, p2, p3, 'aaaa'])
                .then((res) => {
                    console.log(res);
                })
                .catch((err) => {
                    console.log(err);
                });
            // 对象形式返回，调用then方法返回
            // (4) [{…}, {…}, {…}, {…}]0: {status: 'fulfilled', value: 1111}1: {status: 'rejected', reason: 222}2: {status: 'fulfilled', value: 3333}3: {status: 'fulfilled', value: 'aaaa'}length: 4[[Prototype]]: Array(0)
        </script>
    </body>
</html>
